Option (effect)
from Effect-TS
Option (effect)
https://effect.website/docs/data-types/option/
Combining
all
ap
product
productMany
Constructors
fromIterable
none
some
Conversions
fromNullable
code:ts
console.log(Option.fromNullable(undefined)) // None
console.log(Option.fromNullable(null)) // None
console.log(Option.fromNullable(1)) // Some(1)
getLeft
getOrThrow
getOrThrowWith
getRight
liftNullable
liftThrowable
toArray
toRefinement
Do notation
Do
code:ts
import * as assert from "node:assert"
import { Option, pipe } from "effect"
const result = pipe(
Option.Do,
Option.bind("x", () => Option.some(2)),
Option.bind("y", () => Option.some(3)),
Option.let("sum", ({ x, y }) => x + y),
Option.filter(({ x, y }) => x * y > 5)
)
assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
bind
bindTo
let
Elements
contains
containsWith
exists
Equivalence
getEquivalence
Error handling
firstSomeOf
orElse
orElseEither
orElseSome
Filtering
filter
filterMap
partitionMap
Generators
gen
Getters
getOrElse
getOrNull
getOrUndefined
Guards
isNone
isOption
isSome
Lifting
lift2
liftPredicate
Mapping
as
asVoid
map
Models
None (interface)
Option (type alias)
OptionUnify (interface)
OptionUnifyIgnore (interface)
Some (interface)
Pattern matching
match
Reducing
reduceCompact
Sequencing
andThen
composeK
flatMap
flatMapNullable
flatten
tap
Sorting
getOrder
Symbols
TypeId
TypeId (type alias)
Type Lambdas
OptionTypeLambda (interface)
Zipping
zipLeft
zipRight
zipWith
utils
Option (namespace)
Value (type alias)
void